﻿@{
    ViewBag.Title = "用户登录";
}
<div class="row">
    <div class="col-md-12">
        <h2 class="form-signin-heading">用户登录</h2>
    </div>
</div>
@using (Ajax.BeginForm("Login", null, new AjaxOptions() { HttpMethod = "POST", OnSuccess = "OnSuccess", OnFailure = "OnFailure" }, new { id = "loginForm" }))
{
    <div class="form-group has-feedback">
        <input type="text" class="form-control" name="UserName" placeholder="请输入登录账号">
    </div>
    <div class="form-group has-feedback">
        <input type="password" class="form-control" name="Password" placeholder="请输入登录密码">
    </div>
    <div class="form-group has-feedback">
       
       <input class="btn btn-lg btn-success btn-block" type="submit" value="登录系统" />
        @*<a class="btn btn-lg btn-success btn-block " href="@Url.Action("register","account")">注册</a>*@
        
    </div>
}
@section scripts{
    <script type="text/javascript">
        function OnSuccess(data) {
            if (data) {
                var returl = '@Request["ReturnUrl"]';
                if (data.status == 1) {
                    if (returl && returl != '') {
                        location.href = '@Request["ReturnUrl"]';
                    } else {
                        location.href = '@Url.Action("index", "home")';
                    }
                }
                else if (data.status == 3) {
                    location.href = '@Url.Action("index", "Manager")';
                }
                else {
                    alert(data.message);
                }
        }
    }
    </script>
}

